<?php

class SupplierController extends Controller
{
	public $_model;
        public $layout;

//	public function beforeAction($action) {
//		$this->layout = Shop::module()->layout;
//		return parent::beforeAction($action);
//	}

	public function actionView()
	{
        $criteria = new CDbCriteria;
        $model = $this->loadModel();
        $criteria->compare('supplier_id', $model->id, true);
        $dataProvider = new CActiveDataProvider('SupplierProduct', array(
            'criteria' => $criteria,
        ));
        $dataProvider->pagination->pageSize = 5;
		$this->render('view',array(
			'model'=>$model,
            'dataProvider' => $dataProvider
		));
	}


	/**
	 * Returns the data model based on the primary key given in the GET variable.
	 * If the data model is not found, an HTTP exception will be raised.
	 */
	public function loadModel()
	{
		if($this->_model===null)
		{
			if(isset($_GET['id']))
				$this->_model=Users::model()->findByPk($_GET['id']);
			if($this->_model===null)
				throw new CHttpException(404,'The requested page does not exist.');
		}
		return $this->_model;
	}

}
